/**********************************************************/
/* Goblin Defense - A tower defense game for Wii Homebrew */
/* Copyright (C) 2009 Ricardo Bueno Cordeiro              */
/* Licensed under de GNU General Public License v2.0      */
/*   See license_gplv2.txt for detalis                    */
/**********************************************************/

#include <gccore.h>

#include "rock.h"
#include "../draw.h"
#include "../pony.h"

WeaponRock::WeaponRock(f32 xp, f32 yp, f32 dxp, f32 dyp) : x(xp), y(yp) {
	this->vx = dxp * 200.0;
	this->vy = dyp * 200.0;
	this->removable = 0;
}

void WeaponRock::draw() {
	Sprite::draw_sprite(this->get_x(), this->get_y(), 10.0, 10.0, sprite_rock);
}

void WeaponRock::update(u32 step) {
	f32 t = ((f32)step) / 1000.0;

	this->x += this->vx * t;
	this->y += this->vy * t;

	if ((this->x < -256.0) || (this->x > 256.0) || (this->y < -256.0) || (this->y > 256.0))
		this->removable = 1;
}

int WeaponRock::remove() {
	return this->removable;
}

f32 WeaponRock::get_x() {
	return this->x;
}

f32 WeaponRock::get_y() {
	return this->y;
}

f32 WeaponRock::get_radius() {
	return 0.0;
}

int WeaponRock::get_area_type() {
	return WEAPON_AREA_SINGLE;
}

void WeaponRock::pony_near_by(Game *game, Pony *pony) {
	if (this->removable)
		return;

	pony->hit(game, 1, 0);
	
	this->removable = 1;
}
